module Wondercap
module Deployment
  
  module DefaultAreaFinder
    class ConflictingDefaultAreasError < RuntimeError
    end
    
    module_function

    def find_default_area(confs)
      confs.inject nil do |memo,conf|
        default_area = conf.fetch(:default_area, nil)
        default_area = default_area.to_sym if default_area
        raise ConflictingDefaultAreasError.new("there are at least 2 conflicting default areas: #{memo} and #{default_area}") if memo && default_area && memo != default_area
        default_area || memo
      end
    end
    
  end
  
end
end